# Диаграмма 6-7

from FluidClass.FluidSettings import FluidSettings
from ResistanceClass.ResistanceAbstractClass import ResistanceAbstractClass as RAC
from math import pi, log10
from Utilities.MathFunctions import polynom


class CurveCircleSmoothSharpWallPipe(RAC):

    def __init__(self,
                 fluid: FluidSettings,
                 diameter: float,
                 bend_angle: float) -> None:
        super().__init__(fluid)
        self.diameter = diameter
        self.bend_angle = bend_angle
        self.type_name = 'Угольник'
        self.section = 'Круглое'
        self.A = None
        self.C_1 = 1

    def area(self) -> float:
        return pi * self.diameter ** 2 / 4

    def diameter_hydraulic(self) -> float:
        return self.diameter

    def definition_A(self):
        if self.bend_angle < 20:
            # Необходимо рассмотреть исключение, связанное с отсутствием значения
            self.A = 0

        else:
            degree = [20, 30, 45, 60, 75, 90, 110, 130, 150, 180]
            A = [2.5, 2.22, 1.87, 1.5, 1.28, 1.2, 1.2, 1.2, 1.2, 1.2]
            self.A = polynom(self.bend_angle, degree, A, 6)
        return self.A

    def definition_psy(self) -> float:
        degree = [0, 20, 30, 45, 60, 75, 90, 110, 130, 150, 180]
        psy = [0, 0.05, 0.07, 0.17, 0.37, 0.63, 0.99, 1.56, 2.16, 2.67, 3]
        return polynom(self.bend_angle, degree, psy, 6)

    def local_resistance_coefficient(self) -> float:
        return self.definition_A() * self.C_1 * self.definition_psy()

    def frictional_resistance_coefficient(self):
        return 0

    def resistance_coefficient_lambda(self) -> (str, float):

        """
        Данный метод не используется в текущем классе сопротивления
        :return:
        """

    def get_params_geom(self):
        self.params_geom['Угол гиба'] = str(self.bend_angle) + ' град'
        self.params_geom['Диаметр'] = str(self.diameter) + ' м'
        return self.params_geom
